# coding=utf-8

import time
import sys
import keyboard

from PIL import ImageGrab

from .baiDu import BaiDuPAI
from .getText import GetText


def screenShot():
    if keyboard.wait(hotkey='f1') == None:
        if keyboard.wait(hotkey='ctrl+c') == None:

            time.sleep(0.01)

            im = ImageGrab.grabclipboard()
            im.save('imageGrab.png')


for _ in range(sys.maxsize):
    screenShot()  # 截取一张图片

    baiduapi = BaiDuPAI()

    text = baiduapi.picture2Text('imageGrab.png')

    print(text)

    GetText.setText(text)
    # 获取剪切板的内容
    GetText.getText()
